package com.example.mybatisplus.demo.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {

    /**
     * 对应数据库中的主键 (uuid、自增id、雪花算法、redis、zookeeper！)
     */
    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;
    private Integer age;
    private String email;
    private String remark;

    /**
     * 乐观锁
     */
    @Version
    private Integer version;

    /**
     * 逻辑删除
     */
    @TableLogic
    private Integer deleteFlag;
    // 字段添加填充内容
    // @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    // @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 创建人插入时填充
     */
    @TableField(fill = FieldFill.INSERT)
    private String createUserCode;

    /**
     * 更新人插入和更新时填充
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateUserCode;
}
